<?php
/* ========== ########## ========== ########## ========== ########## ========== */
/*                                                                              */
/*   WHMCS v4.1.2 NULLED R4 by FLIPMODE  [ BAD SYNTAX ]                         */
/*                                                                              */
/*                             INTERNAL BAD SYNTAX NULLED VERSION: 2.5.9.6 R4   */
/*                                                                              */
/*   ALL files have been analysed, cleaned and nulled of:                       */
/*     - Call Backs  (100%)                                                     */
/*     - Link Backs (95%)                                                       */
/*     - Licensing  (100%)                                                      */
/*     - Remote Links + URL's                                                   */
/*                                                                              */
/*   WHMCS v4.1.2 RELEASED: 4th November 2009                                   */
/*    -> FIRST v4.1.2 NULL R1: 19th November 2009                               */
/*    -> UPDATED v4.1.2 NULL R4: 27th November 2009                             */
/*                                                                              */
/*   TESTING + VERIFICATION::                                                   */
/*     Files Cleaned, Nulled, Checked, Verified By:                             */
/*      -> FLIPMODE!                                                            */
/*     Decoded By:                                                              */
/*      -> FLIPMODE! + Unknown Decoder                                          */
/*     Tested By:                                                               */
/*      -> FLIPMODE!, LeetWolf, and 12 Anonymous Users...                       */
/*     WHMCS 4.1.2 Supplied By:                                                 */
/*      -> WHM CompleteShit Coder @ WHMCS.com                                   */
/*                                                                              */
/*                                                                              */
/*   IMPORTANT NOTE::                                                           */
/*   PLEASE NOTE THIS IS FOR TRIAL PURPOSES ONLY!                               */
/*                          LIKE IT? THEN BUY IT!                               */
/*                                                                              */
/* ========== ########## ========== ########## ========== ########## ========== */

function select_query ($table, $fields, $where, $orderby = '', $orderbyorder = '', $limit = '', $innerjoin = '')
{
	global $query_count;
	global $mysql_errors;
	if (!$fields)
	{
		$fields = '*';
	}

	$query = '' . 'SELECT ' . $fields . ' FROM ' . $table;
	if ($innerjoin)
	{
		$query .= '' . ' INNER JOIN ' . $innerjoin;
	}

	if ($where)
	{
		if (is_array ($where))
		{
			$query .= ' WHERE';
			foreach ($where as $key => $value)
			{
				if (is_array ($value))
				{
					if ($value['sqltype'] == 'LIKE')
					{
						$query .= '' . ' ' . $key . ' LIKE \'%' . mysql_real_escape_string ($value['value']) . '%\' AND';
						continue;
					}
					else
					{
						if ($value['sqltype'] == 'NEQ')
						{
							$query .= '' . ' ' . $key . '!=\'' . mysql_real_escape_string ($value['value']) . '\' AND';
							continue;
						}
						else
						{
							if ($value['sqltype'] == '>')
							{
								$query .= '' . ' ' . $key . '>' . mysql_real_escape_string ($value['value']) . ' AND';
								continue;
							}
							else
							{
								if ($value['sqltype'] == '<')
								{
									$query .= '' . ' ' . $key . '<' . mysql_real_escape_string ($value['value']) . ' AND';
									continue;
								}
								else
								{
									if ($value['sqltype'] == '<=')
									{
										$query .= '' . ' ' . $key . '<=' . mysql_real_escape_string ($value['value']) . ' AND';
										continue;
									}
									else
									{
										if ($value['sqltype'] == '>=')
										{
											$query .= '' . ' ' . $key . '>=' . mysql_real_escape_string ($value['value']) . ' AND';
											continue;
										}
										else
										{
											if ($value['sqltype'] == 'TABLEJOIN')
											{
												$query .= '' . ' ' . $key . '=' . $value['value'] . ' AND';
												continue;
											}

											continue;
										}

										continue;
									}

									continue;
								}

								continue;
							}

							continue;
						}

						continue;
					}

					continue;
				}
				else
				{
					$query .= '' . ' ' . $key . '=\'' . mysql_real_escape_string ($value) . '\' AND';
					continue;
				}
			}

			$query = substr ($query, 0, 0 - 4);
		}
		else
		{
			$query .= '' . ' WHERE ' . $where;
		}
	}

	if ($orderby)
	{
		$query .= '' . ' ORDER BY `' . $orderby . '` ' . $orderbyorder;
	}

	if ($limit)
	{
		$query .= '' . ' LIMIT ' . $limit;
	}

	$result = mysql_query ($query);
	if (!$result)
	{
		$message = 'Invalid query: ' . mysql_error () . '<br>';
		$message .= 'Whole query: ' . $query;
		if ($mysql_errors)
		{
			echo $message;
		}
	}

	++$query_count;
	return $result;
}

function update_query ($table, $array, $where)
{
	global $query_count;
	global $mysql_errors;
	$query = '' . 'UPDATE ' . $table . ' SET ';
	foreach ($array as $key => $value)
	{
		$query .= '' . '`' . $key . '`=';
		if ($value === 'now()')
		{
			$query .= '\'' . date ('YmdHis') . '\',';
			continue;
		}
		else
		{
			if ($value === '+1')
			{
				$query .= '' . '`' . $key . '`+1,';
				continue;
			}
			else
			{
				if (substr ($value, 0, 11) == 'AES_ENCRYPT')
				{
					$query .= '' . $value . ',';
					continue;
				}
				else
				{
					if ($value === 'NULL')
					{
						$query .= 'NULL,';
						continue;
					}
					else
					{
						$query .= '\'' . mysql_real_escape_string ($value) . '\',';
						continue;
					}

					continue;
				}

				continue;
			}

			continue;
		}
	}

	$query = substr ($query, 0, 0 - 1);
	if (is_array ($where))
	{
		$query .= ' WHERE';
		foreach ($where as $key => $value)
		{
			$query .= '' . ' ' . $key . '=\'' . mysql_real_escape_string ($value) . '\' AND';
		}

		$query = substr ($query, 0, 0 - 4);
	}
	else
	{
		if ($where)
		{
			$query .= '' . ' WHERE ' . $where;
		}
	}

	$result = mysql_query ($query);
	if (!$result)
	{
		$message = 'Invalid query: ' . mysql_error () . '<br>';
		$message .= 'Whole query: ' . $query;
		if ($mysql_errors)
		{
			echo $message;
		}
	}

	++$query_count;
}

function insert_query ($table, $array)
{
	global $query_count;
	global $mysql_errors;
	$query = '' . 'INSERT INTO ' . $table . ' ';
	foreach ($array as $key => $value)
	{
		$fieldnamelist .= '' . '`' . $key . '`,';
		if ($value === 'now()')
		{
			$fieldvaluelist .= '\'' . date ('YmdHis') . '\',';
			continue;
		}
		else
		{
			if ($value === 'NULL')
			{
				$fieldvaluelist .= 'NULL,';
				continue;
			}
			else
			{
				$fieldvaluelist .= '\'' . mysql_real_escape_string ($value) . '\',';
				continue;
			}

			continue;
		}
	}

	$fieldnamelist = substr ($fieldnamelist, 0, 0 - 1);
	$fieldvaluelist = substr ($fieldvaluelist, 0, 0 - 1);
	$query .= '' . '(' . $fieldnamelist . ') VALUES (' . $fieldvaluelist . ')';
	$result = mysql_query ($query);
	if (!$result)
	{
		$message = 'Invalid query: ' . mysql_error () . '<br>';
		$message .= 'Whole query: ' . $query;
		if ($mysql_errors)
		{
			echo $message;
		}
	}

	++$query_count;
	$id = mysql_insert_id ();
	return $id;
}

function delete_query ($table, $where)
{
	global $query_count;
	global $mysql_errors;
	$query = '' . 'DELETE FROM ' . $table . ' WHERE';
	if (is_array ($where))
	{
		foreach ($where as $key => $value)
		{
			$query .= '' . ' ' . $key . '=\'' . mysql_real_escape_string ($value) . '\' AND';
		}

		$query = substr ($query, 0, 0 - 4);
	}
	else
	{
		$query .= '' . ' ' . $where;
	}

	$result = mysql_query ($query);
	if (!$result)
	{
		$message = 'Invalid query: ' . mysql_error () . '<br>';
		$message .= 'Whole query: ' . $query;
		if ($mysql_errors)
		{
			echo $message;
		}
	}

	++$query_count;
}

function full_query ($query)
{
	global $query_count;
	global $mysql_errors;
	$result = mysql_query ($query);
	if (!$result)
	{
		$message = 'Invalid query: ' . mysql_error () . '<br>';
		$message .= 'Whole query: ' . $query;
		if ($mysql_errors)
		{
			echo $message;
		}
	}

	++$query_count;
	return $result;
}

function db_escape_string ($string)
{
	$string = mysql_real_escape_string ($string);
	return $string;
}

$query_count = 0;
?>